<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('批量执行采购订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-execution-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">执行备注：</label>
                <div class="col-sm-8">
                    <textarea id="executionRemark" name="executionRemark" class="form-control" required>批量执行审核通过的采购订单</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">选择账户：</label>
                <div class="col-sm-8">
                    <select id="accountId" name="accountId" class="form-control" required>
                        <option value="">请选择账户</option>
                        <option th:each="account : ${accounts}" th:text="${account.name + ' (' + account.accountNo + ')'}" th:value="${account.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12 text-center">
                    <span class="text-danger">注意：此操作将执行所有审核通过但未执行的采购订单，请确认后操作！</span>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "purchase/execution";
        
        $("#form-execution-add").validate({
            focusCleanup: true,
            rules: {
                accountId: {
                    required: true
                }
            },
            messages: {
                accountId: {
                    required: "请选择财务账户"
                }
            }
        });
        
        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-execution-add").serializeArray();
                $.operate.saveModal(prefix + "/executeAllApproved", data, function(result) {
                    if (result.code == web_status.SUCCESS) {
                        $.modal.msgSuccess(result.msg);
                        $.modal.close();
                        $.table.refresh();
                    } else {
                        $.modal.alertError(result.msg);
                    }
                });
            }
        }
    </script>
</body>
</html> 